# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=shellnoob
pkgver=37.6586133
pkgrel=1
pkgdesc='A toolkit that eases the writing and debugging of shellcode.'
groups=('blackarch' 'blackarch-debugger' 'blackarch-exploitation')
url='https://github.com/reyammer/shellnoob'
arch=('any')
license=('MIT')
depends=('python2')
makedepends=('git')
source=("git+https://github.com/reyammer/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -e 's/env python$/env python2/g' -i "$pkgname.py"
  sed -e "s|README|/usr/share/doc/shellnoob/README.md|g" -i "$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/lib/python2.7/site-packages"
  install -dm 755 "$pkgdir/usr/share/doc/$pkgname/samples/x86-linux"

  install -m 755 "$pkgname.py" \
    "$pkgdir/usr/lib/python2.7/site-packages/shellnoob.py"
  ln -s "/usr/lib/python2.7/site-packages/shellnoob.py" \
    "$pkgdir/usr/bin/shellnoob"

  install -m 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -dm 755 "$pkgdir/usr/share/doc/$pkgname/samples/x86-linux"
  install -m 644 samples/x86-linux/* \
    "$pkgdir/usr/share/doc/$pkgname/samples/x86-linux"
}

